﻿using LJ.Abstractions.Config;
using Microsoft.Extensions.Configuration;
namespace LJ.Host.Abstractions.Config;


public class ConfigManager(IServiceCollection serviceCollection, IConfiguration configuration) : IConfigManager
{
    private readonly IServiceCollection _serviceCollection= serviceCollection;
    private readonly IConfiguration _configuration = configuration;

    public void Add<TConfig>(string key, string path) where TConfig : class
    {
        _serviceCollection.Configure<TConfig>(
            key,
            _configuration.GetSection(path));
    }

    public void Add<TConfig>(string path) where TConfig : class
    {
        _serviceCollection.Configure<TConfig>(
                    _configuration.GetSection(path));
    }

    public void Bind(string key, object instance)
    {
        _configuration.Bind(key, instance);
    }
}